HNHacker News
TopNewBestAskShowJobs

dmlorenzetti

2,350 karma · joined May 18, 2009

I work on problems of air quality and energy conservation in buildings. Mostly I write simulation and optimization tools, using mainstream languages like C, Python, and F95.
submissionscomments
dmlorenzetti··on Trump Administration Hardens Its Attack on Climate Science
Not to mention the loss of experience and knowledge as people in the affected programs move on to other, potentially more stable, and potentially more lucrative, employment.
dmlorenzetti··on Naked mole-rats: A case study in biological weirdness
The Errol Morris documentary "Fast, Cheap & Out of Control" has a segment on mole rats [0].

I think that movie would appeal to a lot of HN members -- it's broadly about people who obsessively pursue some interesting corner of skill or knowledge, and how that makes the world a richer place. Kind of like the "Fred Dibnah, Stepplejack" series that I learned about on HN ([1], and I know it made HN about 7 years ago as well).

[0] https://www.imdb.com/title/tt0119107/

[1] https://news.ycombinator.com/item?id=9796254

dmlorenzetti··on Finland’s Hobbyhorse Girls
Not saying your main point is wrong, but Black Beauty wasn't written to appeal to young girls. It is an urgent call to treat horses better, and has been called "the most influential anticruelty novel of all time."

https://en.wikipedia.org/wiki/Black_Beauty

dmlorenzetti··on Tips and tricks to write LaTeX papers in with figures generated in Python
This is not what you asked for, since it still requires a separate file. However it might be close enough to what you want, and -- for complicated expressions -- possibly even better.

You can write (or derive) the expression using sympy, then have sympy generate a numpy expression that can be evaluated. Sympy can also generate the LaTeX code for any expression. So while that isn't an in-LaTeX solution, it may be close to what you want.

Johansson's "Numerical Python" shows several examples of this. I will scavenge one of his examples below (trusting it falls under "fair use", and hoping I transcribe it correctly -- note I have left out the imports). The example uses sympy to generate and plot Taylor series expansions of sin(x).

The key bit to look for in the example is `sympy.lambdify()`.

    sym_x = sympy.Symbol("x")
    x = np.linspace(-2 * np.pi, 2 * np.pi, 100)

    def sin_expansion(x, n):
        return sympy.lambdify(sym_x, sympy.sin(sym_x).series(n=n+1).removeO(), 'numpy')(x)

    fig, ax = plt.subplots()
    ax.plot(x, np.sin(x), linewidth=4, color="red", label='exact')
    colors = ["blue", "black"]
    linestyles = [':', '-.', '--']

    for idx, n in enumerate(range(1, 12, 2)):
        ax.plot(x, sin_expansion(x, n), color=colors[idx // 3],
            linestyle=linestyles[idx % 3], linewidth=3,
            label="order %d approx." % (n+1))

    ax.set_ylim(-1.1, 1.1)
    ax.set_xlim(-1.5*np.pi, 1.5*np.pi)

    ax.legend(bbox_to_anchor=(1.02, 1), loc=2, borderaxespad=0.0)
    fig.subplots_adjust(right=.75)
I highly recommend the book. It's full of nuggets like this.
dmlorenzetti··on ParaSail Programming Language: parallel programming language
It does make the code a little verbose, but in my experience with this (in modern Fortran), it can be rather nice.

Explicitly tagging the construct you are closing makes it easier to understand long swaths of code (where the start of a loop or function may have disappeared off the top of the page by the time you scroll to the end of the loop/function). It can also make compiler error messages more helpful.

I don't see it in the ParaSail code samples, but where this really shines in Fortran is letting you name loops. This makes the control structure much easier to understand (again, especially in longer loops). So you can have code like

    loop_timesteps: do
        ...
        loop_converge: do
            ...
            loop_actors: do
                ...
            end do loop_actors
            ...
        end do loop_converge
        ...
    end do loop_timesteps
Now to break out of a loop, you can be explicit about which one you want to break out of. Not only does that help with code clarity, it also allows you to jump out of a deeper nesting than just the immediate one, which means you don't have to set flags, or repeat tests, in order to get to where you want to go.

I realize that most programmers on HN will be thinking "if I had a loop or function that long, I would break it up into smaller functions, and express my nesting that way."

That's generally good advice, but it's not always useful in numerical code (which ParaSail seems to target).

In numerical code, you tend to run through those loops a lot of times, and you tend to have a lot of local variables (for example, in a physics calculation you might take primary variables like pressure, temperature, and mass fractions, and use them to find a lot of related values like humidity ratio and molar concentration and gradient estimates &etc). So the overhead of making large numbers of function calls with long parameter lists can become too much.

dmlorenzetti··on Proto-internet trolls: Struensee and press freedom in 18th century Denmark
Enquist is one of my favorite authors, and Royal Physician's Visit among the many reasons why. That said, I have almost stopped recommending his work to others, as it seems to be hit-and-miss.

Nobody I know hates his work, but nobody takes to him quite the way I have. Royal Physician is fairly conventional in structure and tone, but Enquist's more personal work -- the work that feels like it comes from his deep interior life, like Downfall, and Captain Nemo's Library -- seem even harder for a lot of people to get into.

dmlorenzetti··on Ask HN: Is there a modern “power on to basic” computer, for kids to learn on?
Micro:bit has a lot going for it.

Comes with a 5x5 LED array, an accelerometer, two physical push-buttons, three capacitive sensors, and a bluetooth antenna, already on-board. It means you can start programming without having to plug in to a breadboard and wire up your inputs. You can also hang external sensors and actuators off of it, but the point is you don't need to in order to move beyond toy demonstrations.

It was designed specifically for education, so there are lots of beginner-oriented tutorials available, as well as educator-oriented lesson plans.

As fusiongyro points out, you can program it using three high-level languages. The graphical language lets you toggle to the Javascript version, so there's a clear learning path built-in. These provide high-level commands, such as "get the orientation", or "get the number of button presses since the last query", which makes programming it very straightforward.

It removes a lot of toolchain fussiness. Just run an online editor, or a desktop editor (Mu). These produce binaries that you drag onto the Micro:bit, which mounts to your desktop like an external drive. You can also program it from a smart phone or iPad.

dmlorenzetti··on The Awful German Language (1880)
Also this bit from Connecticut Yankee

"She had exactly the German way; whatever was in her mind to be delivered, whether a mere remark, or a sermon, or a cyclopedia, or the history of a war, she would get it into a single sentence or die. Whenever the literary German dives into a sentence, that is the last you are going to see of him till he emerges on the other side of his Atlantic with his verb in his mouth."

dmlorenzetti··on Argue with your customers
My father worked for a large software company for many years. I remember him telling me how they successfully responded to a Request For Proposals with a much smaller proposal that said, in essence, "You don't know what you're actually looking for; pay us $ to help figure that out before you pay $$$ to build it."
dmlorenzetti··on Push to Weaken U.S. Endangered Species Act Runs into Roadblocks
I don't have the foggiest idea why it is important to protect endangered species in and of itself... Every species that has ever existed has gone extinct... Human endeavor is more important

If every species goes extinct, and if there is no reason to protect any species in and of itself, then what makes human endeavor so damn important?

This is the logic of the powerful, a pure might-makes-right argument. I see what I want, and I take it. It's easy to kill things, or at least hard to avoid killing them, when they get in our way, so don't worry about it.

In fact, profess to not having the "foggiest notion" why you might want to worry about it, even though the arguments in favor (biodiversity, makes life more wonderful, we don't know how the web is connected, etc.) are part of mainstream culture, and not at all hard to discover if you honestly wanted to try.

dmlorenzetti··on Ask HN: What are the things keep in mind while giving/preparing for a tech talk?
Try framing your material in the assertion-evidence [0] style. Not only does this lead to more informative presentations, I find it helps me organize my story better.

Briefly, rather than using topic titles ("Experimental Setup", "Results"), use assertions ("Sampling occurred over 5 days", "Sunlight causes significant degradation") as titles. Then the bulk of the slide is some information, preferably graphical, that supports the assertion. Reading the titles in order should give you a strong sense of the presentation content.

I strongly recommend "The Craft of Scientific Presentations" by Michael Alley, which covers the assertion-evidence approach, and a host of other practical topics.

[0] https://www.assertion-evidence.com

dmlorenzetti··on Does the entorhinal cortex use the Fourier transform? (2013)
Some time in the late 1970s, I heard a lecture by a researcher at the Air Force Institute of Technology, who stated that if you took Fourier transforms of an optical illusion, and then reconstructed the image while progressively dropping the highest-frequency terms, the reconstructed image would eventually demonstrate the illusion.

This suggests that our sensory perceptions (and possibly, in the current research, our memories) lose fine detail in a way that can be analogized, if not explained directly, in terms of discarding or losing high-frequency information.

dmlorenzetti··on What's Going on in Your Child's Brain When You Read Them a Story?
All three versions came from the Web site of Canadian author Robert Munsch.

Hearing Robert Munsch read his own stories can be a revelation. He puts so much energy into the reading, in a way that kids seem to really enjoy. He also often deviates from the published text. Listening to him made me willing to take a lot more risks as a reader.

I read "Paper Bag Princess" to my daughter's kindergarten class, and then played them Munsch's rendition [0]. Whenever I go back, the kids ask if they can hear an author reading their own book.

[0] https://www.youtube.com/watch?v=hIPrb-sA6Uo

dmlorenzetti··on A Hawaiian island got about 50 inches of rain in 24 hours
Sometimes, when a climate-denial comment on HN seems especially troll-like, and when I have time to kill, I'll look at the comment history of the apparent troll.

Occasionally the person's comments only include political opinions, but I would say that, for the majority of these posters, the technical/programming comments outweigh the political ones.

I don't know about other discussion boards. HN is the only forum on which I actively participate -- maybe because it's so good at self-policing that the trolls don't tend to survive long here.

dmlorenzetti··on At full speed with Python: a book for self-learners
I've had mixed results using Calibre (https://calibre-ebook.com/).

In all, I've converted 3 PDFs to Kindle format -- one is OK, one is a slog to read, and the third I forgot I was reading a converted version. Have never tried using it to convert a LaTeX-generated document of my own, though.

dmlorenzetti··on The Case for Writing Papers in Economics Using FaKe LaTeX [pdf]
Not only is the MS eqn editor slow, it also doesn't work consistently across versions of Word. I have a work colleague whose equations never show properly on my machine when he sends over Word docs.

By contrast, LaTeX works the same everywhere -- to the extent that SymPy can derive an equation, output it as LaTeX, and it goes right into a paper or presentation without issues.

dmlorenzetti··on Hardcoded Password Found in Cisco Software
There's a new-ish book, "Secure by Design", that makes this point -- and shows ways for ordinary devs to design for security without explicitly thinking about security.

I really like this book so far (it's still in the early access stage of writing).

https://www.manning.com/books/secure-by-design

dmlorenzetti··on Ask HN: Best way to learn modern C++?
Coincidentally, Pearson just announced a 40% off sale for all their C/C++ books (in honor of Stroustrup receiving the Draper Prize).

http://www.informit.com/promotions/programming-with-c-and-c-...

dmlorenzetti··on Floating point error is the least of my worries (2011)
This example shows a hazard of floating-point, but it does not show that the FP error is worse than modeling error.

Here, the problem arises because the equational system is ill-conditioned. Yet you present the system as if the coefficients are known exactly.

In reality, this ill-conditioned model can arise for two reasons:

+ The equations represent a physical system that is ill-conditioned -- a slight change in the system can produce a huge change in its output. So where did those coefficients, with their 8 digits, come from? A minor error measuring the coefficients will throw off your "correct" solution. In this case, modeling error is every bit as important as floating-point error.

+ The physical system is not poorly conditioned, but the model is. In this case, by definition, modeling error overwhelms floating-point error.

So the essay still advances the correct perspective -- if you are modeling an ill-conditioned system, you had better spend a lot of time worrying about the effects of modeling errors, before you get hung up worrying about FP errors. And if you know the system is ill-conditioned, then poor conditioning in the model is one of the things that an experienced analyst will be prepared for.

dmlorenzetti··on The Algorithm Design Manual (2008)
You don't have to "hate rigor" in order to like non-technical treatments of a subject.

One reason I like the book is it gives a high-level overview of what algorithms are available to solve a problem, and a sense of which is most appropriate to my problem. If I need rigor after that, I can go to an appropriate source.

dmlorenzetti··on Modelica
Are QSS methods general and how do they compare practically to more traditional explicit time integrators?

The original idea of QSS was to bolt an ad hoc step length control mechanism onto the most basic explicit method, forward Euler. So at its core, the original QSS method is exactly a traditional explicit integration, except that the length of any individual step is not adjusted based on feedback about how well the step actually did.

Why would you do that? The motivation was to enable parallel execution of large modularly-composed systems, without getting bogged down with iterations. Basically every important design decision in QSS methods comes directly from, or is at least deeply influenced by, the desire to avoid iterations between components in the simulation. They want to avoid large communication overheads, and they want to enable components to step forward in time as independently of each other as possible. The dream is to enable the simulation of large systems by just connecting components together, and letting each one broadcast what it plans to do over the next time step, and how long it will do it. Thus the core idea of QSS is to choose the step length a component can take before it takes the step, and to not get too inquisitive about how well the step actually did.

I always thought that QSS methods would benefit from adapting a trust region approach to at least control errors going forward in time, but as far as I know, they never did.

By the way, later versions of QSS introduced some implicit-flavored methods. I believe they are still only implicit in the local information (i.e., only state variables defined within a component get an implicit model), and that state variables defined in other, communicating, components still have an unchanging, forward-projected model. However, it's been a long time since I looked at those methods, and I might be wrong about that.

dmlorenzetti··on Modelica
If you're interested in circuit-like systems, Modelica is probably a good fit. Electrical networks seem to be a core use case for the developers/presenters of Modelica. Also I know it has been used to model airflow networks in buildings, using the multizone approach which typically uses a nodal formulation.

If you've read much about Modelica, you probably know this, but one key to thinking about Modelica is to recognize that you're not defining a nodal system anymore -- at least, not in the way that an electrical engineering textbook would define it. Yes, you can define a network, which can have resistive/capacitive/inductive elements strung between nodes. However, in EE-speak, you would then form either the nodal equations or the mesh equations, depending on whether you wanted to add up currents into nodes, or voltages around loops. But in Modelica, you just state the component relations, and the rules that apply to the connections between components. Then the solver decides how to set up the system equations. Typically the solver uses graph-theoretical techniques to reduce the number of unknowns, or to achieve other nice system properties. So for example if you had a bunch of components in series, you might expect the common current to be a state variable, whereas in another part of the system you might find voltage state variables. Modelica encourages you to think about the components, and let the solver handle the system assembly and solution.

I believe Modelica got its start in the automotive simulation world, where there is a need for large-scale lumped-parameter multiphysics models. I'm not sure how ACSL fits in. In the building simulation world, there was also an earlier language called Neutral Model Format that attacked many of the same problems as Modelica.

It's been a long time since I studied bond graphs, but I would say Modelica is much more general, since it allows discrete as well as continuous components, and since it doesn't require the formalism of identifying the equivalent of voltages and currents in each domain (don't remember what bond graph theory calls those). I think Modelica even allows components to be defined by algorithms, although obviously those components may not have mathematical inverses that can be easily manipulated when assembling the system.

dmlorenzetti··on Modelica
Modelica sees a lot of use in building energy simulation [0], [1].

My impression is that the solver landscape is a little uneven (the solver reads a Modelica model and computes its solution). For one thing, open-source solvers seem to lag behind the commercial implementations, in terms of capabilities. Even with commercial solvers, there seems to be a non-negligible amount of work around taking correct models that don't run, and reformulating them to let the solvers run them. Caveats -- I don't work on this personally, but know people in my division who do. Also, these impressions are a few years old, and doubtless the situation is improving as time goes on.

[0] Library of component modules for building energy and control systems (http://simulationresearch.lbl.gov/modelica/)

[1] "Spawn of EnergyPlus", a prototype next-gen whole-building energy solver (https://energy.gov/eere/buildings/downloads/spawn-energyplus...)

dmlorenzetti··on Schools warned over hackable heating systems
It would be relatively easy for mischief-makers to switch off the heaters... The risk is limited because ... it should be possible for building managers to notice what is happening and manually override

If you really wanted to be malicious, you would curtail fresh air, rather than cut off heat. It would be harder to notice, and would give you an attack that didn't depend on cold weather.

And arguably the long-term consequences would be greater. The kids who got cold would bundle up and complain, leading to a (possibly energy-wasting) fix. The kids who got a low-grade headache and fatigue every afternoon might conclude "I'm just not cut out for learning."

dmlorenzetti··on Laptops Are Great, But Not During a Lecture or a Meeting
I have a colleague who makes mind-map style notes, either on paper or via software. He doesn't try to capture everything that's said. Rather, he notes key ideas, and identifies/imposes structure to the conversation.

It can actually be informative to look over his shoulder as a meeting progresses, to see what loose ends are still dangling, and where people focus the most attention.

For myself, I've moved to markdown-style in my handwritten notes. It isn't as fluid as mind maps, but the bullet points and headings still bring out structure, and the number of sub-bullets under any given item can hint to me if I haven't understood how things are going at a fine enough or coarse enough level.

dmlorenzetti··on Revisited: Watership Down
Adventure, bravery, friendship, loyalty, love, life, and death.

All these, plus another component I personally enjoy in adventure books -- flawed characters who complement each other, and so become collectively stronger than they stand as individuals. For example, Bigwig has an amazing character arc, where he learns to subordinate his strength to Fiver's vision and Hazel's leadership.

Other examples include the foursome in "The Three Musketeers" (who explicitly arrange their affairs to contribute equitably from among their talents, money, and time), and "Kidnapped" (where David Balfour and Alan Breck have to learn to trust each other in order to negotiate the dangers they face on each other's behalf).

dmlorenzetti··on Remembering Laika, Space Dog and Soviet Hero
For cultural references, in my opinion you can't beat Hallstrom/Jonsson's "My Life as a Dog", whose main character ponders the fate of Laika while his own life undergoes traumatic changes.

https://www.rottentomatoes.com/m/my_life_as_a_dog/

dmlorenzetti··on Remembering Laika, Space Dog and Soviet Hero
For those in the SF Bay area, the Chabot space center has a lot of old Soviet space hardware -- including a training capsule like the one in the picture at the top of the article.
dmlorenzetti··on What to Know Before Buying an Air Purifier to Clear Wildfire Smoke
Except the part where I spelled "breathe" incorrectly :-)
dmlorenzetti··on What to Know Before Buying an Air Purifier to Clear Wildfire Smoke
Most rooms do have dead spaces where the "age of air" is higher than the well-mixed parts of the room. So you can expect some of the room air to go through the filter more, and some less.

There are a few reasons this effect probably doesn't matter so much. First, the dead spaces tend to be places where people don't breath -- in closets, under furniture, in corners, near ceilings, etc. Second, where people do go, they bring thermal plumes and activity-generated eddies, which tend to mix up room air. In fact, the act of breathing also provides mechanical power that will promote mixing. The filter itself also blows air, giving more mixing than if the filter wasn't present.

The net effect is that the participating volumes of the room, where people tend to breath, probably get mixed at a rate similar to, or greater than, the rate at which the filter scrubs the air. Any non-participating volumes act as slow-filling and slow-releasing reservoirs, which delay the room's response to changes in outdoor concentrations.

I would worry more about the filter only cycling the air 4-5 times per hour. That's probably faster than the effective release rate of the indoor sources with which Mr. Hefferman (the expert cited in the NYTimes article) seems to have have experimented. However, it's the same order of magnitude at which outside air gets into most houses (especially in the parts of California affected by these fires). My gut feeling is that implies the filter isn't going to keep up so well -- though I'd want to model it to say anything definitive.

← PreviousPage 2 of 14Next →