On the way to achieve minimalism and essentialism

Why I still haven’t found a life partner

Yesterday I downloaded an audio book from Audible.com – which is called The Mathematics of Love, written by Hannah Fry who seems to be a pretty charming mathematician, who also from time to time making some YouTube Numberphile videos such as this one.

Never mind… The point is in her book she mentioned a method I used previously on a beer conversation with my lovely colleagues, a method can help you calculate how many potential life partners are out there waiting for you to be find. (I guess every single man or woman with a little of brain function would have probably thought about the same question at least once when he or she was half way intoxicated and there happened to be a young couple across the bar kissing as if they were the main actors of the show that evening…)

Anyway, the method is, actually very simple, just using the number of total potential partners, multiply by a few factors each from a certain perspective can help you estimate how many percentage of them are actually can be your life partner. It said to be the same way scientists try estimate the number of highly evolved civilizations that might exist in our galaxy (Drake equation), mentioned by Hannah in her book when referring a paper called Why I don’t have a girlfriend – by Peter Backus.

$G = N \cdot f_W \cdot f_A \cdot f_S \cdot f_U \cdot f_{B1} \cdot f_{B2} \cdot f_{P1} \cdot f_{P2} \cdot f_f$

I remember I did the calculation, once, for the fun of it, together with my colleagues, and the result was quite shocking. So I am going to do it here again:

Suppose I live in Denmark, and the whole population is around N=6,000,000, and we assume:

• $f_W$ = the fraction of people in DK who are women = 0.5;
• $f_A$ = the fraction of the women in DK who are age-appropriate = 10 years out of 70 years (suppose the age is evenly distributed) = 1/7;
• $f_S$ = the fraction of the women with the right age are single = 0.5;
• $f_U$ = the fraction of the women who have a university education = 0.26 (no offense but I have the same reason with the guy mentioned in the paper Why I don’t have a girlfriend;
• $f_{B1}$ = the fraction of the women with the right age with the right education who I find physically attractive = 2 out of 10 = 0.2;
• $f_{B2}$ = the fraction of the women with the right age with the right education who find I physically attractive = 2 out of 10 = 0.2; (Let’s say I am average looking, if you don’t agree, comments below and I will reduce this value);
• $f_{P1}$ = the fraction of the women with the right age with the right education who we both find attractive and who think my personality is acceptable also enjoy being with me, or you may call it have a word to say between = 0.5;
• $f_{P2}$ = chance that I enjoy being with her, same above = 0.5;
• $f_f$ = sadly because I am a foreigner who don’t speak Danish yet so maybe half of the women in the end decided not to date me = 0.5.

Thus, we can easily calculation G, which is the possible number of ladies in Denmark could become a life partner of mine:

$G = 6e10^6 \cdot 0.5 \cdot {1 \over 7} \cdot 0.5 \cdot 0.26 \cdot 0.2 \cdot 0.2 \cdot 0.5 \cdot 0.5 \cdot 0.5 = 279$

My goodness, only 279 women are out there in DK could be my life partner, based on a positive estimation.

However since I live in a town called Odense, suppose if I don’t go out of the town and just try to meet some local people, with the population of 190,000 in Odense, the number G becomes 8.8. It seems not that bad, but if you look at the numbers again, you will see, statistically, out of every thousand girls at the right age, there’s only a half girl could potentially become my life partner. What a lonely planet ?!

The next question to think about is, how to identify those 279 ladies in Denmark, I mean at least efficiently using my spare time. At the moment, I have no idea 🙂

Transmission Loss Wiki Page Created

Here just to copy and paste some key content from Wiki page just for the convenience of myself 🙂

$TL = L_{Wi} - L_{Wo} = 10 \log_{10} \left\vert {S_i p_{i+}^2 \over 2} {2\over S_o p_o^2 }\right\vert = 10 \log_{10} \left\vert {S_i p_{i+}^2 \over S_o p_o^2}\right\vert$

Transmission loss (TL) (more specifically in duct acoustics) is defined as the difference between the power incident on a duct acoustic device (muffler) and that transmitted downstream into an anechoic termination. Transmission loss is independent of the source and presumes (or requires) an anechoic termination at the downstream end[1].

Transmission loss does not involve the source impedance and the radiation impedance inasmuch as it represents the difference between incident acoustic energy and that transmitted into an anechoic environment. Being made independent of the terminations, TL finds favor with researchers who are sometimes interested in finding the acoustic transmission behavior of an element or a set of elements in isolation of the terminations. But measurement of the incident wave in a standing wave acoustic field requires uses of impedance tube technology, may be quite laborious, unless one makes use of the two-microphone method with modern instrumentation.[1]

$TL = 10 \log_{10}\left( {{1 \over 4} \left\vert { A + B {S \over \rho c} + C { \rho c \over S} + D }\right\vert^2}\right )$

What are the simplest things one can do to make oneself happier?

When I was in a dark period I instituted a simple rule that changed my life.

Rule: When I arrive home from work, the very first thing I tell my wife is the best thing that happened that day.

No exceptions. No complaining. Just the best thing that day, even if it was just a good cup of coffee. This had the effect of starting our evening off on a positive note and it changed our relationship.

What are the simplest things one can do to make oneself happier?

Changing CSS to customize your Wordpress theme (Manifest)

With quite a bit of effort, I finally could relax and enjoy my blog’s nice and neat looking theme. Shortly speaking, there are not so many those “very minimal” type of theme on WordPress, after comparing around, I found these two theme very good but each has something that is not perfect in my opinion:

• Penscratch – Good looking but font and line-space too big for me. The font color seems a bit too light. Also the setup of the background color causing the Latex equation to have a dark color background by default 😦
• Manifest – Good looking as well, but the main content width is too narrow. It also cannot change the width based on your browser condition or your screen size of your device. As a modern website it should be self-adapted. Another thing is this theme doesn’t have a side bar where you can show some links such as categories or archives.

In order to make my blog looks better, I started to look into the customize CSS option that WordPress provides. Firstly I tried on Penscrath theme but in the end couldn’t solve the Latex color problem. Then I switched to Manifest, downloaded it’s CSS from the link above, search key word “width” inside, found many things like this:

#site-wrapper {
margin: 0 auto;
width: 500px;
text-align: center;
position: relative;
}


Which means that the “site-wrapper” is set exactly to 500px. No matter how wide your screen is. Thus by changing all the constant defined width in the original CSS to something like “50%”, then the webpage will show up in a nicer way, especially in my case that I use a very wide screen.

After I did those changes, weather it looks good or not, you should be easily see if you are viewing this post. (Suppose I am still using Manifest as the theme).

If you want to try these changes for yourself, try copy paste the following code to the WordPress CSS editor:

#site-wrapper {
width: 51.8%;
}
#site-description {
width: 60%;
}
#main-nav ul {
width: 100%;
}
#main-nav ul ul {
width: 100%;
}
#core-content {
width: 100%;
}

h1 {
text-transform: uppercase; /* Your Blog Title*/
}
h2 {
text-transform: none;
}

.commentContent {
float: left;
width: 51.8%;
margin-left: 22px;
}
font-size: 1.4em;
}
legend span {
width: 51.8%;
}

#footer {
width: 51.8%;
}
.footer-content {
width: 100%;
}


With the code above your Manifest Theme should look the same as mine which you are looking at right now. And it’s nice that Latex by default can show up in a very nice way 🙂

$e^{i\pi} + 1 = 0$

Special thanks to my friend Jean Popescu for providing help and suggestions on this.

How do I learn to code? What language should I start with?

Answer by Roshan Choxi on Quora:

It’s been my sole focus to answer this question for the last two years, and I think a lot of the resources mentioned here are great but I’ve noticed there are three strategies that successful students consistently use better than anyone else regardless of what resources they use:

1. Focus on habits, not goals
2. Learning alone is painful
3. Build things

Note: some of this is borrowed from my answer to another Quora question: How can I prepare for Bloc?

1. Focus on habits, not goals

It seems counterintuitive that you shouldn’t focus on goals, but hear me out — it’s all about leverage. Anyone who works with me knows that I dweebishly reference the R’as Al Ghul scene in Batman Begins pretty much 3-4 times a day:

Our investors at Bloc are getting tired of board meetings starting with Batman clips.

R’as tells Bruce:

If you focus on building the habit of programming for 20-30 hours a week, you will reach your goal of being a web developer. If you focus on the goal of being a web developer in X months, you get nothing from that but stress and insecurity about how far along you are. Focus on the habit, not the goal. Rub your chest, your arms will take care of themselves.

So here’s what you should do right now: put 15 minutes a day on your calendar to spend time programming. Don’t do more than 15, just focus on doing 15 minutes a day. If you can do it successfully with no excuses for a week, try bumping it up to 20 minutes a day. Don’t try to overextend yourself by doing an hour a day right off the bat, this is going to be a 10,000 hour marathon so we’re focusing on developing the habit right now. The number of minutes you put in isn’t as important as you showing up each day.

2. Learning alone is painful

When I was learning web development, the two biggest social components to my learning were having a mentor and belonging to a community.

Having a mentor

I worked at a small startup called merge.fm while in college. I learned more in the summer I spent working with one of their cofounders than I did in the entire previous year at my university. There’s just something about working alongside an expert who knows more than you that really accelerates your learning, you’re able to pick up on how they think and unveil what you don’t know you don’t know. There’s a reason why mentorship used to be the de facto standard of learning a new trade, it’s very effective.

Belonging to a community

For me, the two communities I belonged to were the Illini Entrepreneurship Network (a student organization at my university) and HackerNews (a large hacker/startup oriented online community).

I didn’t learn what objects and classes were from HackerNews, but I learned a different category of things. I learned that nobody likes Javascript. I learned that Rubyists are the hipsters of programming. I learned that Bret Taylor, Rich Hickey, and John Carmack are programming gods, and that software companies that are truly serious about coffee have kitchens that look like meth labs.

In short, I learned how to talk shop. That turns out to be important when you’re working with other developers, but it’s also the thing that makes you feel like a developer.

3. Build things

In the first year of learning web development, I built:

• A Digg Clone (from a Sitepoint book on Rails, I believe it’s out of date now though)
• An E-Commerce App (from Agile Web Development with Rails 4)
• A GeekSquad-esque App (personal project)
• A Realtime, Online Classroom (personal project)
• A Foreign Language Flashcard App (class project)

I think building real projects is important for many reasons, but the most important one to me is because it’s fun. That’s something that is tragically lost in classical education, but I think it’s important enough to be on this list. Look for resources that show you how to build things, http://ruby.railstutorial.org/ is a good one.

4. Be a cockroach

I secretly added a 4th item for those of you who’ve stuck around to read this far down the page.

Paul Graham once told the founders of Airbnb:

“You guys won’t die, you’re like cockroaches.”

You’ll probably want to quit learning how to code at some point. Like anything worthwhile, it’s difficult and will make you feel stupid at times. This is why #1 on this list is so important — stop worrying so much about whether you’re making progress or how much longer it’ll be until you feel like you’ve “made it.” All you have to do is focus on showing up, for 10-30 hours a week. Be as mindless as a cockroach about everything else, and don’t “die.”

I made the statement years ago which is often quoted that 80 percent of life is showing up. People used to always say to me that they wanted to write a play, they wanted to write a movie, they wanted to write a novel, and the couple of people that did it were 80 percent of the way to having something happen. All the other people struck out without ever getting that pack. They couldn’t do it, that’s why they don’t accomplish a thing, they don’t do the thing, so once you do it, if you actually write your film script, or write your novel, you are more than half way towards something good happening. So that I would say was say my biggest life lesson that has worked. All others have failed me.

Woody Allen

How do I learn to code? What language should I start with?

The issue

So the problem finally arrives – when a COMSOL acoustic model gets very large and still we would like to perform analysis up to a relatively high frequency range (for exp. above 2000Hz), a grate number of mesh cells are needed in order to give a good representation of the system. Typically for our case, the mesh number went up to around 400K elements, and my desktop computer with 16G of RAM is simply not enough for the default direct MUMPS solver, as shown below.

So if you are new to COMSOL acoustics and encountered the same issue above, here is the “easy” solution: use a FGMRES iterative solver instead of the default direct solver, together setting a geometric multigrid as a preconditioner.

The cure

1. Expand Study, Solver Configurations, Solver 1 and Stationary Solver 1
2. Right-click Stationary Solver 1 and choose Iterative. (Note the default Direct solver will become disabled afterwards.)
3. Select the newly generated Iterative 1 solver, in the setting window, General section, select Solver: FGMRES.
4. Right-click Iterative 1 solver and choose Multigrid. (Note thedefault Incomplete LU node will become disabled afterwards.)

After this, the calculation can be carried out smoothly. Honestly there are lots of new jargon such as GMRES and FGMRES which are new to me as well in the process and it seems a bit confusing. But if you just simply setup up the model as mentioned above, it will probably work for you as well.

However after going through the help documentation perhaps those following tips under are worth paying attention to.

More tips one may need

• Use GMRES as a smoother only if necessary because GMRES smoothing is very time- and memory-consuming on fine meshes, especially for many smoothing steps. (Or in other words, use FGMRES when you are not sure about what you are doing.)
• Try to use as many multigrid levels as needed to produce a coarse mesh for which a direct method can solve the problem without using a substantial amount of memory.
• If the coarse mesh is still too fine for a direct solver, try using an iterative solver with 5–10 iterations as coarse solver.

Above words are copied from COMSOL Help Document. More details are found in the Acoustics Module User’s Guide under the Modeling with the Acoustics Module chapter. Under Fundamentals of Acoustics Modeling section, see Solving Large Acoustics Problems Using Iterative Solvers.

Also, there is a Test Bench Car Interior model in the COMSOL model library you can refer to. But it generally illustrates the same setting suggested above.

Summary

In the end, by simply a few clicks here and there, the big mesh issue was easily solved. RAM usage from 8G plus reduced to around 2G and it solves fast as well. Simply amazing!

List of abbreviations

MUMPS  – Multifrontal massively parallel sparse direct solver.
GMRES  – Generalized Minimum RESidual  iterative method.
FGMRES – Flexible Generalized Minimum RESidual iterative method.

And special thanks to the help from COMSOL by Mads J.H. Jensen and Kristian R. Jensen for their support on this topic.

Modalverber – kan, skal, vil, må

Infinitiv, Nutid, Datid, Førnutid
at kunne, kan, kunne, har kunnet
at skulle, skal, skulle, har skullet
at ville, vil, ville, har villet
at måtte, må, måtte, har måttet

at kunne

at kunne udtrykker en evne (ability) eller en mulighed (possibility)
Eks:
Hun kan tale engelsk. (evne)
Han kunne ikke komme til Oles fødselsdag. (mulighed)
Hvad kan der være i vejen med dig? Du er jo helt rød i ansigtet.(mulighed)

at skulle

at skulle udtrykker en plan (planned future) eller en ordre (order)
skal nok udtrykker et løfte (promise)
Eks:
Jeg skal i biografen kl. 19. (plan)
Du skal være hjemme kl. 16. (ordre)
Jeg skal nok ringe i aften. (løfte)
Min bror skal til lægen kl.13. Han har det ikke så godt. (plan)
Efter en blodprop skal han gå til kontrol hver uge. (ordre)
-Havd skal vi have at spise af grønsager i dag? Broccoli? (plan)
-Det synes jeg ikke! Jeg kan ikke udsta broccoli! (ability – evne) [kan ikke udsta = cannot stand with]

at ville

at ville udtrykker et ønske (wish) eller en vilje (will)
Eks:
Hun vil gerne være jurist. (ønske)
Han vil ikke bo i København. (vilje)
Vil du ikke have en hovedpinetablet? Jeg tror, det hjælper.(asking for wish, providing suggestion)
Vil du ikke sidde lidt? Du ser ikke ud til at have det så godt. (same above)
Min far ville aldrig gå til lægen før i tiden. (ønske) [før i tiden = in the past]
Vil du være sød at række mig salten? (inquiry)
Nej! For meget salt kan være meget usundt. (mulighed)

at måtte

at måtte en tilladelse (permission) eller et forbud (ban)
Eks:
Man ikke ryge på skolen (forbud)
I går måtte min kone og jeg tage tidligere hjem. Hun var pludselig blevet dårlig.(tilladelse)
Du sandelig ikke ryge herinde. (ban) [sandelig = indeed]

A Geometry Trap for SolidWorks FlowSimulation

Geometry check results – Invalid contacts and invalid parts

I have been using SolidWorks Flow Simulation for sometime, and usually, in most cases, it works just fine. However this week, I encountered this small geometry issue which seemingly brought me a big headache.

The first geometry trap (and yeah, there is a second trap blow, just keep reading), as the plot shows above, is making the Flow Simulation cannot find the correct flow domain geometries. By using the Check-Geometry tool provided by the Flow Simulation software, it gives errors called “Invalid contacts” and “Invalid part”.(One will see this is not a leakage issue, if he or she continues reading on.)

This is somehow a little bit strange because the issue is within a sub-assembly, which has been successful  through the air-tight-check on the simple tool FloXpress, done by my colleague. But when I include this sub-assembly in to the top-assembly, the above errors show up while doing geometry check and no flow domain can be obtained… Anyway, all the problems are located in the part connection shown as below:

Problem parts

Note the problem happens on this internal geometry, which also indicates that the previous issue is not a leakage issue, but a geometry error, or invalid geometry. If one make a cut plot and zoom in to the connection where the pipes meet the baffle, one will see some of the intersection parts look like things below (the two figures above):

The idea of drawing the baffle which should be perfectly contact with the pipe is: firstly draw a block with a perfect round top surface (A) which has a diameter exactly as pipe diameter plus shell thickness (above lower figures); secondly make a shell operation through surface (B) and (A).

The reason those parts afterwards don’t contact well have showing up miss-alignments is simply because, some part of the edge of round surface A is connected to some fillets.

Look at the upper pictures on the right side, since there is a fillet surface marked as blue color, when adding a shell performance, the thickness is probably calculated based on the norm direction on the fillet surface thus the shell body will be slightly bent as shown in the red line. This will give a miss-alignment in the model after adding the pipe in.

So in short, the first geometry trap can be concluded as: be special caution while doing a shell performance on a surface which is connected to some fillet or other tilted surfaces.

——————————————————————————————-

Initially, after we saw the above miss-alignment, we decided a quick fix by using the “cavity” tool, simply cut the intersecting parts out from the baffle by using the pipe body.

This solves the problem of “flow geometry not found”. But there is still error or warning messages on some invalid contacts. We didn’t pay attention to that and just went on with the simulation however the following picture is what we got after we started running the simulation:

Yes, you saw it, a software crash or dead…

So here is the second geometry trap – the real trapIf one does not solve ALL the “Invalid contact” or “Invalid parts”, found by the flow simulation geometry check tool, even though one can get the flow domain and proceed with simulation, one may later suffer simulation/software frozen issue…

Also one thing worth mentioning is that, while those invalid contacts exist, it is extremely lagging or time consuming while doing some normal simulation setup operations and geometry check operations. So if you suddenly feel a new model is slow than usual while setting up, there probably might exist those “invalid” stuff in your model. I suggest you fix them first before going any further.

I am not sure whether the second trap can happen in all circumstances but in our case, later on we simply changed the baffle part and make sure the fillet is ended before it touches the boundary of the round surface which is used for guide a shell operation, all problem solved.

So if you have read so far, here is a post written by Christopher Ma –  4 Things to Do Before Every Flow Simulation Analysis. I believe if one follows the process described within this article, make sure all the invalid things are fixed, the chance of software/simulation crash can be minimized.

Thank you for reading so far, hope this article can give you some hints and as always, do have fun with simulations 🙂

Test post for using Latex in Wordpress

$\LaTeX$ $, is$ it really that easy?

$latex i\hbar\frac{\partial}{\partial t}\left|\Psi(t)\right>=H\left|\Psi(t)\right>&s=2$

$i\hbar\frac{\partial}{\partial t}\left|\Psi(t)\right>=H\left|\Psi(t)\right>$

$latex i\hbar\frac{\partial}{\partial t}\left|\Psi(t)\right>=H\left|\Psi(t)\right>&bg=ffffff&fg=0000ff&s=4$

$i\hbar\frac{\partial}{\partial t}\left|\Psi(t)\right>=H\left|\Psi(t)\right>$

$latex E=mC^2&bg=ffffff&s=3$

$E=mC^2$

A page I use all the time for writing equations by Latex

$E=mC^2$

A weight function for an engine source sound level empirical equation

Those days I tried to spend some time on making a COMSOL model for calculating the tailpipe radiated noise. One of the first thing to do this is to build up an engine source strength model in to COMSOL. There is already some empirical equation one could get (for example the empirical source strength equation used in the software called SIDLAB).

However during the process I encountered a relatively difficult issue -The empirical equation only give values as the input frequency is a engine firing frequency. If one inputs a random frequency between two engine firing frequencies, one gets a really high and unrealistic value.

In order to make the model of source strength better, a new empirical function is needed, which can considerably drop the sound level between each firing frequencies. To form this new function, I need to develop a weighting function in order to make the empirical engine source sound level equation (upper plot left) to shape more like a real results (upper plot right). Hopefully in the end the original function multiplying the weight_function will give me a good engine source strength model.

In order to achieve this, I started doing some manipulation on a cosine function. Detailed function shaping process can be seen on those pics:

In the end, the weight function can be written as:

W(freq) = 1+(COS(2*Pi*(freq/F1 – 1)) -1) / ( n_low+1+freq/F1*n_fast);

which looks like the following pattern if one uses n_low=4 and n_fast=2, with F1=90;

Note that:

n_low: define how deep weight function can go. Must above 0, recommend 3, 4 or 5, the larger the value, the less deep it goes. In the beginning of the weight function, the first drop can go down from 1 by -2/(n_low+1). In our previous plot case, where n_low=4, this means the early drop of the function can go down to (1-2/(4+1) ) = 0.6.

n_fast: define how fast the weight function disappears (stop oscillating and become as one), must above 1, recommend use 2, the larger the faster it disappears.

In the end, by putting the weight function on the original function (upper plot left), a “nice” looking function is generated (upper plot right).

In the future I will have to take some real engine source data measurement and compare with the output of the function. By tuning n_low and n_fast and other engine parameters used in the original empirical equation, one should be able to get a simple but averagely nicely fitted empirical function.

We will see…