← Back to context

Comment by knolan

5 years ago

I’m a lowly mechanical engineering lecturer. I use Jupyter notebooks to teach fluid mechanics[0]. I make videos of fluid flows with Blender and embed them with the notes along with some basic Python code examples so that students are aware of how basic code can make an Engineer’s life easier (even if Matlab is the standard platform).

I also embed simple 3D models with pyGEL3D[1]. It’s fine but very limited. I’m always blown away by this gentleman’s work when it comes up here on HN and would like to use JavaScript instead, but I’ve no idea where to start. Can anyone recommend a good book or online course that would put me on the right path?

[0] https://nbviewer.jupyter.org/github/nolankucd/MEEN20010/tree...

[1] http://www2.imm.dtu.dk/projects/GEL/PyGEL/

Why do you have to learn JS? If you just want to make a web app and add some interactive 3D models on it, there're some Python libraries can help with that, like: https://github.com/streamlit/streamlit https://github.com/wang0618/PyWebIO https://github.com/plotly/dash

  • Why learn JS? I guess it’s because I think it’ll be a useful skill that will allow me to do more in the future, not just find a better way to embed 3D models in a notebook.

    It might be useful to build tools for research projects, interactive elements for assessment etc.

    The bulk of my coding is work Matlab and an increasing amount of Python. JS would allow me to to more web based stuff.

For the graphics: - https://webglfundamentals.org/ - https://threejs.org/

For general JS: - https://developer.mozilla.org/en-US/docs/Web/javascript#tuto...

There's other stuff like build tools, cross-browser, and other stuff, but that's likely to be confusing and not super necessary to begin with. The above should be enough to get you running with what it sounds like you want to do.

I appreciate you sharing those links. I'm trying to learn mechanical engineering stuff myself, if you have any further useful learning materials I would love to see them.

  • Much appreciated. I’ll be adding to the fluid mechanics notebook this summer.

    What areas are you interested in?

    • Mechatronics, which is why I'm interested in mechanical engineering. I guess this mostly implies servomechanisms, kinematics, motors.

Also I would trade you mech eng tutoring for JS tutoring, if you've got the time.

  • I wish there were more opportunities for people to learn via “cross training” like this.

    I’d love to learn more about a number of engineering disciplines by helping people who know those fields, learn how to implement the algorithms and mathematical calculations they need in Python and simultaneously, learning more about those algorithms and calculations in order to best implement them and show how best to use Python for these tasks.

    But unfortunately such opportunities are few and far between outside academia and other learning oriented environments in my experience.

    • I love this idea. The best way to get academics to buy in would be to have some clear outcome such as a publication or funding opportunity.

      There are a lot of clunky engineering tools that would benefit greatly from professional software development. Computational Fluid Dynamics software in particular is just plain awful in terms of usability for beginners.

      4 replies →

There's an array of javascript libraries to choose from, but maybe you would find Observable (reactive javascript notebooks) to be a good substitute for Jupyter.

Observable is geared toward the use of d3.js (essentially a library for drawing charts and graphs) which can be a bit intimidating, but you can use other libraries as well. For 3D, regl seems to be a good option. It's a library which makes using WebGL a bit more convenient. Here's an example of an Observable notebook that uses regl: https://observablehq.com/@rreusser/contour-plots-with-d3-reg...

Check out R. Reusser's other notebooks too. My guess is that choosing a set of JS libraries/tools to learn is the hard part, here, once you've committed to javascript.

http://regl.party/

  • Thanks, I’ll take a look.

    I use Jupyter because it’s something that the students are finding used more and more when they go on industrial placement. Matlab is extremely popular in engineering but Python is growing.

    My notebooks are deliberately simple so it’s not I ntimidating for students who are frequently terrified by code. The point is to show them that some basic readable code can help them solve problems and avoid going too deep into the weeds.

I'm on mobile so linking is a bit of a schlep.

1. MDN is a good starting point to learn Javascript.

2.Then the three.js library for 3D in the browser.

3. Maybe P5.js as well for 2D.