Jupyter Notebooks for the study of advanced topics in Fluid Mechanics

In recent years, Jupyter Notebooks have become a very useful free and open‐source tool in teaching, as they allow you to combine text, images, mathematical expressions, links and code into a single document. This gives students an interactive document with which they can experiment and learn with the help of high‐level mathematical calculus. In Fluid Mechanics, it is very common for students to deal with complex computations that take away attention from the Mechanic, especially in advanced topics such as Rheology, Turbulence, or Boundary Layer. The subject “Advanced Fluid Mechanics” is an elective one of the last year of the Bachelor's degree in Industrial and Aerospace Technology Engineering at the Terrassa School of Industrial, Aerospace and Audiovisual Engineering at the Universitat Politècnica de Catalunya. This subject has three ECTS credits and has been taught since the academic year 2020–2021 This subject complements the compulsory subject Fluid Mechanics and is developed in 6 weeks with 5 h of class each week. This work presents Fluid Mechanics modules with Jupyter Notebooks that complement the syllabus given in the compulsory subject. An elective subject is presented where subjects of Fluid Mechanics per week are studied independently, using different Python tools: symbolic calculation, modeling of experimental data, statistical analysis, numerical calculation, and so forth. The main goal is for the student to focus on mechanical concepts and actively learn to use the tools available, especially open source, to do the associated mathematical calculations.


| INTRODUCTION
Fluid Mechanics (FM) involves mathematical tools as diverse as Differential Equations in both Ordinary and Partial Derivatives, Geometry, Vector and Tensorial Analysis, Integrals, Complex Variables, Statistics, Numerical Calculus, and the list goes on. This means that students sometimes lose sight of the mechanical concepts in the middle of a web of mathematical equations, or some students interpret the concept of solving FM problems as looking for the correct mathematical formula that fits the given data [8,23]. This often leads to resolutions without any physical meaning.
Today, students are always using their computers, smartphones, and tablets. The high rate of device penetration globally poses new challenges and universities can continue this trend. The educational field is developing new challenges. Online education, distance learning, and other educational computing scenarios are increasingly being used. In recent years, different types of methods have been developed (artificial intelligence, mobile applications, virtual reality, game development…) that use electronic resources to improve students' understanding. These methods are known as e-learning. Several of these methods have been applied in higher education, especially in universities where education is continuously updated with new tools. The number of mobile applications used in universities is increasing, as it is shown in Refs. [15], [17], and [34]. Using new technologies in the teaching process provides a lot of benefits including saving time, having faster and more accurate evaluation tools, creating new learning environments full of visual aids such as animated media, high-quality pictures, threedimensional (3D) models, and interactive way of learning to attract students to learn and provide better outcomes.
Teaching and learning strategies based on multiple technologies can be integrated into course content to provide the most effective learning and teaching. As computers have moved from laboratories to classrooms and homes, much research has investigated their use for educational purposes. Since computer software can be a potentially powerful tool, it is important to find out which techniques are best and subsequently employ these techniques to enhance the learning experience. In particular, computers can be used for a variety of multimedia techniques, and it is important to characterize the circumstances of their successful use. The use of electronic media has been widely recognized as an effective and efficient tool in delivering course materials, as it is shown in Refs. [16] and [18]. Considering Engineering as an applied science, simulations can be used to complement education methods, specifically in undergraduate engineering degrees, because it allows the students to work with real and complex situations in a controlled and risk-free environment. Interactive computer simulations yield dynamic and visual representations of physical phenomena and allow students to interact with a simplified version of a scientific process or system which is built upon a mathematical model. For example, Radinschi et al. [40], Botelho et al. [7], and Mateo et al. [30].
On the other hand, open and free software has gained popularity in recent years, especially for research and educational purposes. In particular, the high-level language Python has increased its acceptance due to its simplicity, large user community, and availability of powerful libraries and tools [25,26,33]. Jupyter [32,36] and JupyterLab are the evolution of the IPython interactive shell [44], which is not only aimed at Python but also at other languages, such as R or Julia. There is a huge collection of Jupyter Notebooks dedicated to Data Science, mainly with the pandas library [31,37,47], and it is extensively used for Computing Sciences, Engineering, Science, Signal Processing,… A large collection of these notable Notebooks are available on Jupyter's Github site [27]. However, with respect to FM, there are Jupyter Notebooks about Computational Fluid Mechanics [3] and Aerodynamics [4], and also other innovative methodologies, such Project Based Learning [35] or Flipped Classroom [1,20,23] but, to the authors' knowledge, there is no Jupyter Notebook focused to the study of topics related to FM in general.

| Context of the study
The subject Advanced Fluid Mechanics (AFM) is an elective subject in the last year of the Bachelor's Degree in Industrial and Aerospace Engineering at the Terrassa School of Industrial, Aerospace and Audiovisual Engineering (ESEIAAT) [Universitat Politècnica de Catalunya (UPC)]. This subject has three European Credit Transfer System (ECTS) credits and has been taught since the 2020-2021 academic year. It is an elective subject that serves to complement the compulsory subject FM of 4.5 ECTS credits. The subject AFM is developed in 6 weeks with 5 h of class each week and is taught in English. The number of places offered is 20 students.
In the final year of the Bachelor's Degree, or in the Master's Degree, students must be given tools more similar to those found in the world of work. On the other hand, it is interesting to introduce students to the world of free software (Linux OS, Apache, WordPress, Mozilla, GIMP…). The international community dedicated to free software in general, and education in particular, has not stopped growing and promoting activities, as it is shown in Ref. [14].
This work presents the material developed in the subject AFM, five topics of FM that are usually explained superficially in the compulsory subject. In this subject, they are presented in more detail and with a different methodology that allows students to make autonomous learning material. Being a subject in the last year of the Bachelor's Degree, it is hoped that the students have the appropriate knowledge of FM that is taught in the compulsory subjects. In addition, they also generally have a basic knowledge of programming, including highlevel languages (usually Matlab, but sometimes Python or R as well).

| Objectives and research questions
The main objective of this work is as follows: • To provide students with an alternative study methodology, to complement the syllabus of the compulsory subject of FM, making the learning of physical concepts active instead of passive and not conditioned by the limitations of the knowledge of mathematics.
The complementary objectives that are pursued, to achieve the main objective, are as follows: • To familiarize students with the Jupyter Notebook study, writing, documentation, and math calculation tool. • To generate independent modules with study material with advanced topics in FM.
The research questions posed in this work are the following: • Does the use of Jupyter Notebooks compared to the classic content presentation offer better academic results? • Are students satisfied with the use of these new tools?

| State of the art
Nowadays, a new method used for e-learning is the knowledge pills or virtual laboratories. The pills are widely used for theoretical explanations. Knowledge pills are a tool that has been used recently. This type of resource is useful in the e-learning processes, exclusively for distance teaching or to support classroom teaching.
The main source of inspiration for this proposal is the work of Professor Lorena Barba [5,3]. Barba and her group, from George Washington University (Washington), have for years made a strong commitment to the ecosystem represented by Jupyter Notebooks to teach, especially at distance, the methodology behind Computational Fluid Dynamics (CFD). An example of their efforts is the MOOC (Massive Online Open Course) they have published since 2017 [2]. Cardoso et al. [9] also report on the use of Jupyter Notebooks in engineering courses at the University of Coimbra, assessing that students have shown an improvement in the learning process.
More recently, Golman [21] proposes a set of Jupyter Notebooks for the numerical analysis of chemical and enzyme-catalyzed reactions in a porous pellet. Suárez-García et al. [45] present an experience of using Jupyter Notebooks as teaching material in the field of Structural Analysis. Specifically, they report the results of using Jupyter Notebooks in two lab sessions and at the end conduct a survey with 28 students about the experience. In general, they conclude that the acceptance has been positive and the Jupyter Notebooks have served for a better understanding of the theory by the students.
But if there is one publication that has had a major impact it has been that of Helen Shen in Nature [44] which has accumulated more than 200 citations in Google Scholar. Shen, however, still talks about the Ipython Notebook instead of the Jupyter Notebook, which was created precisely in 2014 from Ipython. In this article, Shen describes the benefits of creating, sharing, disseminating, and publishing documents, code, and data using Notebooks.

| Description of the Jupyter Notebooks
A Jupyter Notebook is a text file, which is saved with the .ipynb extension, and has the structure of a JSON [38] and can therefore be easily read and exchanged between users. A Jupyter Notebook file can be opened with a multitude of programs on almost all the available platforms. Basically, a Jupyter Notebook combines text, mathematical formulas, links, figures, videos, and, most importantly, executable code. The text is formatted with Markdown [22], which is a very simple way to write text with the most basic format (titles and sections, bold, italics, list, numbering, code, links, images, etc.). The main idea behind a Jupyter Notebook is to create a computational narrative, if possible, following the 10 rules that Rule et al. [43] suggested, and which are summarized here: 1. Tell a story to an audience. 2. Document the process, not just the results. 3. Use cell divisions to clear the steps. 4. Modularize the code. 5. Register the dependencies. 6. Use version control. 7. Build a pipe. 8. Share and explain your data. 9. Design your Notebooks to read, run, and explore.

Advocates open research.
Jupyter Notebook is becoming a standard in many fields of Science, Technology, and, mainly, Data Science, as indicated by the "Software System Award" that the Association of Computing Machine (ACM) awarded to Fernando Pérez, creator of Jupyter Notebook, in 2017. The public repositories of GitHub hosted 2018 almost three million Notebooks.
The set of Jupyter Notebooks presented here are designed to be independent of each other, except for the first one, which serves as an introduction to the tools that are being to be used throughout the whole project. In this way, the order of the Notebooks can be changed in the classroom, some books can be skipped, or, more importantly, other Notebooks can be added.
At the present moment, the project is composed of six Jupyter Notebooks. The first one, numbered with 0 following the use with python indexed items, is an introductory module with more basic concepts about python, installation, and load of modules, and a description of the main modules used in the project: numpy, matplotlib, scipy, pandas, sympy, and statsmodels. The next Jupyter Notebooks explore exciting topics in FM as lubrication, capillarity, rheology, boundary layer, turbulence, … by using statistical tools, symbolic computation, numerical methods, function definitions, etc. The Notebooks are intended to be self-explanatory and closed. The phylosophy of making a narrative, such as telling history, has been considered in all the Notebooks.
Each Notebook has an assignment associated. This assignment can be solved individually or in groups of maximum three students, and it can be done during class hours if the students have time or as homework. The solution has to be delivered in a maximum period of 1 week.
In the next sections, the Notebooks are briefly described. The details of each Notebook can be found in the online version of the course [10].

| Introduction to Python, Jupyter Notebook and main modules
In this Notebook, the fundamentals of python programming are introduced at the very beginning. After that, students learn how to install and load the main modules that are going to be used during the course. Then in several sections, each module is explained following some simple examples. Following the book by Johansson [26] sympy is used to solve the 1-D first-degree ordinary differential equation (ODE) for Newton cooling law, and the second-degree ODE for the damped harmonic oscillator. Also, more related to FM, the simple equation of motion for a free rocket is introduced.
In the next section, the pandas module for data analysis is introduced with a very easy example of subject grades and teachers. Finally, statsmodels and scipy are used to look for a model by the fitting of a scatter of twodimensional (2-D) points into a curve.
The assignment for this Notebook is to find the emptying time of a conical vessel. It is a simple problem that is explained in the fundamental courses of FM, but with some physical simplification. Here, students are asked to solve the problem with sympy and numerical integration overcoming the mentioned simplification.

| Microflows. Lubrication and capillarity
Reynolds number is in this case defined as When it is very small, below 1, because the scale of the flow is of the scale of microns the Navier-Stokes equations are linearized (this is known as Stokes equations) and usually can be solved analytically. The Reynolds equation [41,48] can be derived for the case of lubrication between two close bodies, with a narrow gap, not necessarily uniform, and with a relative movement between them. Figure 1 depicts this case of lubrication between bodies.
Reynolds equation is derived with sympy. Students can see how to use symbolic computation to get useful ODE than can be integrated. The code to obtain the solution of Stokes equation follows import sympy as sp x,y,t,mu = sp.symbols(x,y,t,mu) and, with the particular case of When it is imposed that the integral of this profile cannot be function of x (continuity condition), that is easily done with ReynoldsEq = sp.Eq(intU. diff(x),0), Reynolds equation is obtained and pressure distribution is computed by integrating the velocity profile and isolating the pressure gradient. intU = sp.integrate(Sol.rhs, (y,0, h(x))) q = sp.symbols(q) exp_dpdx = sp.solve(intUq,p(x).diff (x)) p_eq = sp.Eq(p_, exp_dpdx[0]) Finally, it is integrated where the constant C 1 will depend on the known value of the pressure on some point x.
As an example, in the Notebook the case of a tilting- solved. The case of a journal bearing (see Figure 2), where a load W displaces the shaft and produces an eccentricity e is left as the assignment for this Notebook. In this case, the distance between the surface is given by , where θ is the angular position with respect to the minimum distance, h 0 , and R a and R b are, respectively, the shaft and the housing radia.
In this notebook, the equation of Young-Laplace for interface liquid-gas with surface tension is also presented, and it is used to find the shape of this interface.
The main objective of this Notebook is the solution of differential equations with the help of sympy.

| Rheology
Rheology is an interesting branch of FM that deserves more attention than it is usually given. It deals with the study of the deformation of materials, both solids, and fluids [24,49]. In the present case, the Notebook focuses on fluids, and it analyzes simple models as the Ostwaldde Waele law and its analytical computation of velocity profile in a pipe, and also more complex behaviors, such as a viscoelastic unsteady flow that has to be solved with finite differences code for the case of the Maxwell model. Figure 3 shows a result of this computation, where the dimensionless velocity u u where η and ρ are, respectively, the viscosity and the density of the fluid, R is the pipe radius and p′ is the gradient of the pressure in the pipe, with a dimensionless parameter , where λ is the relaxation time of the Maxwell model. It is suggested to students to modify the code to inspect the behavior with a more complex model, like the Voight-Kelvin one.
As an assignment for this notebook, it is proposed to use the module scipy.curve_fit to fit a set of experimental data, taken at the Centre for Industrial Rheology [11], that are shown in Figure 4. To get the data, and convert the points in the graphic into numbers in a file, a plot digitizer is used [42]. It is clear that the data do not correctly fit the Ostwald-de Waele law, and it is suggested to use the Carreau model, given the link to the Wikipedia page.
The main objectives of this notebook are the use of curve_fit module of scipy, that is, really useful for modelization and, also, the use of the Finite Difference Method or the solution of nonlinear partial differential equations (PDE).

| Turbulence
The subject of turbulence is so complex and wide that it would deserve a complete course of several tens of hours. In this Notebook, it is analyzed only from an experimental and statistical point of view, showing the main characteristics scales of a one-component of the velocity acquired in a wind tunnel, in the wake behind an airfoil. The measurement of the velocity was done with a Dantec Constant Temperature Anemometer with a hot-wire probe, and data are provided to students with a CSV file. The CSV data are composed of 17 columns, one for each y position of the probe in the normal direction to the wake and the airfoil plane, and 1000 rows, for the measurement for 1 s of the xvelocity with a frequency of 1000 Hz.
Using the pandas library, very popular in Data Engineering, students compute important turbulence characteristics like F I G U R E 4 Rheological behavior of a group of creams and lotions [11].
• Turbulence intensity • Turbulence Reynolds number • Kolmogorov and integral time scales • Energy dissipation rate • Velocity auto-correlation • Probability Density Function • Energy Spectrum For the assignment, quite simply, students are encouraged to find the equivalent space magnitudes by using Taylor's hypothesis [39].

| Boundary layer
Boundary Layer is a mandatory topic in the majority of fundamental FM textbooks, and it is also included in the syllabus of the compulsory subject of the Bachelor's Degress in our School. Nevertheless, the study of the boundary layer, even for the simplest case 2D laminar regime in a planar plate without pressure gradient, requires the solution of a nonlinear system of two PDEs. The classical Blasius theory [28,48] uses algebraic manipulation with dimensionless magnitudes to reduce it to a third-order ODE, where η stands for a dimensionless distance to the wall, and f is the dimensionless primitive of x-velocity. The vertical component of velocity is related also to f ′ with the continuity equation. This equation has no analytical solution, and Blasius solved it by approximation of power series [6]. In this notebook, this equation is solved as a boundary value problem, where the boundary conditions are the following: This ODE is numerically solved with the solve_bvp method of the scipy.ode package, and the solution is compared with the parabolic approximation. Finally, the von Kármán momentum equation is introduced and studied, as well as the turbulent boundary layer theory, along with the wellknown log law.
As an assignment for this notebook, it is proposed to find a power law approximation by fitting the points obtained with the log law and use the von Kármań equation to find the growth law for a turbulent boundary layer.

| Compressible flow
The theory of one-dimensional compressible flow, even without friction, requires the solution of complex algebraical nonlinear equations. In this Notebook, a set of functions to relate the thermodynamical, physical, and geometrical variables are coded, following rule 4 described in Section 2.1. Some of them are left to students for practicing. Also, as a very important point, the proper documentation of the functions is required, to help a future user or, more frequently, the developer himself or herself.
The topics covered in this Notebook are • Isentropic flow • Normal shock wave • Oblique shock wave • Prandtl-Meyer expansion fan As an example, Figure 5 shows the ratios of variables across a normal shock wave, as computed by the functions developed in the Notebook.
As an assignment for this last Notebook, it is suggested to write a function, properly documented, to compute the deflection angle in an oblique shock wave.

| Students' assessment and surveys results
Two indicators have been considered to evaluate the proposal. The first is the academic performance of the students, compared to the performance of the students themselves in the previous compulsory subjects. The second indicator is the results of the surveys, both the officials of the [UPC] and the SEEQ survey used by the authors. The sampling of the marks was carried out on 18 students from the 2 academic years analyzed, 2020-21 and 2021-22. Students who are not noticed in any of the two subjects (because they have not been presented) and foreign (Erasmus) students have been eliminated. That is, only students who have completed both subjects in the same Bachelor's Degree have been considered. The first 12 students were from the 2020-21 academic year and the last 6 from 2021 to 22 academic year. The small number of students last year is due to the fact that more than half were foreigners. The results are shown in Figure 6.
Regarding the students' opinions, two different surveys have been considered. First, there is the official [University] survey, which consists of three main questions: 1. I found the contents of the subject interesting.  Table 1.
Secondly, a SEEQ (Student Evaluation of Educational Quality) [19,29] survey has been carried out in two editions of the subject presented in this report, and the compulsory subject FM of the Bachelor's Degree of Industrial Technologies. It should be noted that the lecturer was the same in both subjects; Not all the SEEQ questions, which are more than 40, are presented here, but only the five that have been considered most relevant in relation to the subject and the methodology. The questions and the results are presented in Figure 7. In both surveys, the student's answers are given on a scale of 5 values: 1: Strongly disagree, 2: Disagree, 3: Neutral, 4: Agree, and 5: Strongly agree.

| Jupyter Notebooks discussion
The following are the quality principles enunciated by Chickering and Gamson [13] for a teaching innovation action. The relationship with the present proposal is commented out with each of the principles.

Stimulate contact between teachers and students.
Although it is not the strong point of the proposal, as the material could be used without the intervention of the teacher, it is tried to enhance this stimulation through more or less simple exercises that often require communication between teacher and student. 2. Stimulate cooperation between students. The assignments that are delivered and evaluated are carried out in groups of three. It is tried in the classroom, in addition, to avoiding the competitiveness between students and groups. The goal is to learn as much as possible, not to get the highest grade. In this way, collaboration between groups is encouraged, in classroom and in the digital classroom, through forums where all deliveries are shared. 3. Stimulate active learning. This is the most important point of this proposal. Students take almost no notes but are encouraged to explore, play, and change notebooks. They are encouraged to change the input and interpret the results. They are asked to look for alternative ways to solve the same problem. Throughout all Notebooks, many of the tools used are unexplained, and links to Wikipedia, GitHub repositories, and so forth are provided for information. 4. Provide timely feedback. Each week a topic that is independent of the rest is worked on. At the end of the week, they have an "Assignment" that they have to hand in the following week. Once delivered, the Notebooks are posted on a Moodle forum with access for all students. In this way, students can analyze each of the deliveries, and give a comment and even a mark. Feedback is often given to each other and, more importantly, they see different ways of solving the same problem. Obviously, the teacher puts the final mark on the delivery, but it does not go far from what they put. 5. Spend time on the most relevant tasks. As explained in Section 1, one of the motivations for this proposal is that students often do not learn FM because they are stuck with mathematical concepts and calculations. The aim of this proposal is for students to focus on the concepts of FM by learning to do mathematical calculations, and visualize them, with appropriate tools. 6. Communicate high expectations to students. Students end up creating their own Notebooks. At first, they seem skeptical, but after the first 2 weeks they see that it is not that complicated and they end up doing really interesting work. 7. Respect the different talents and forms of learning. In fact, the course could be done completely autonomously. It is designed so that students can meet small challenges gradually and at their own pace. In the classroom, it is common for students to finish work very quickly and either play with Notebooks, start working on assignments, or collaborate with other groups.
The fact that all the material is in a repository in a well-documented way makes it easy for any teacher to take charge of the subject at any time, just by making a fork of the repository or working in a branch which can then be combined with the main trunk (merge). The Jupyter Notebooks presented in this work, by definition, are fully documented and accessible to anyone. Not only can the course be transferred to any department, school, or university professor but, being developed in English and available in a public repository, it can be used by anyone in the world. To use and contribute to the proposal, it is advisable to know and use Git and GitHub, reading previously any of the books by Chacon and Atraub [12] or by Tsitoara [46]. This repository is constantly being updated with large contributions from students. More modules can be generated with topics that may be of interest to certain students, such as: • Aerodynamics (experimental data processingerror propagation, reliability, modeling…). • Pipe flow (development of a tool for calculating pressure losses in transport pipes). • Potential flow (calculation with complex variable).  Of course, the methodology described in this work can be extended to other subjects. It is very common to be used in computer science, but it can also be used in other branches of Engineering, or in Physics, Mathematics, Chemistry, and so forth.
Jupyter Notebooks is becoming a standard for the research and teaching community in recent years. It allows for combining text, images, mathematical expressions, and codes in one document that can be opened and executed in several applications and platforms. However, except for the particular case of CFD, its use for FM does not seem to be extended. This work proposes a FM course structured with Jupyter Notebooks that are presented as independent modules that encourage active and collaborative learning. The main objective is to introduce students to work on scientific and technological tools with Python, such as symbolic calculation, data analysis, ODE and PDE solution, and numerical computation, using it with advanced topics on FM, such as lubrication, rheology, compressible flow, … The Jupyter Notebooks are distributed in a public repository in Github so that not only the students but also any academic member can contribute and extend the course.

| Students' assessment and surveys discussion
There is, in general, a significant increase in marks, as can be seen in Figure 6. In part, this increase can be attributed to the fact that it is an elective subject of a higher course, with fewer students, and therefore easier to obtain better performance. However, the fact that there are students who have dropped the mark, especially in the last year, suggests that, on average, the increase in the mark is largely due to the change in methodology.
On the one hand, there is a significant increase in the assessment by students, as can be seen in Table 1, from an average assessment of less than 4 out of 5 to 4.8 in all three questions. Nevertheless, it should be considered that the sample is much lower in the case of AFM than in the other three compulsory subjects, and therefore the result is much less reliable. A larger sample should be available in the coming years to draw more definitive conclusions. Table 2 shows that the average score is slightly lower in the case of the subject proposed in this work in the first four questions, but higher than the last ("This course is better than most I have done at this university") where AFM is a little better valued.
From Figure 7a-e it is obvious how the opinion between "Agree" and "Strongly agree" is exchanged between the subjects FM and AFM. While the "Agree" option (score 4) is generally more common in FM, the situation changes with "Strongly agree", which is more common in AFM. However, this frequency reversal is not high enough to exceed the average.
The results of the official surveys of the [University] reflect an increase in the assessment of the subject. However, this impression could be false due to the sample difference between the two options. It would be useful to wait another academic year or two for more samples in the case of AFM.
From the results of the SEEQ survey, it can be concluded that the new methodology of using Jupyter Notebooks does not displease the students, although it does not excite them either. The opinion of the students is quite unbalanced: either they like it a lot or they do not like it at all. The opinion is different in the compulsory subject of FM, where most students give a medium-high rating.
Finally, it may be useful to reflect here the comments left on the SEEQ questionnaire by three students: "The course and the dynamic methodology make a subject such as Advanced Fluid Mechanics more enjoyable and much more affordable to learn. Added to that, the course has concepts and works as an introduction to python which is also a big plus." "Very good class, loved discovering the approach of notebooks in code. Also, the subjects were interesting and the class was dynamic, and the workload was heavy but necessary to understand all the fluid mechanics concepts." "The course materials were helpful for learning about the subject. Very well-structured code and illustrations were possible. Course works were structured so that it would be rewarding to do them with group."