@@ -221,7 +221,7 @@ def format_level(value):
221221 return f"{ value :g} "
222222
223223
224- def contour_figure (record , values , levels , title , comment , markers = (), extra = None , color = VALUE ):
224+ def contour_figure (record , values , levels , title , comment , markers = (), extra = None , color = HEAT ):
225225 """Contour lines of a nodal field, labeled with their values, on the outline of the domain."""
226226 fit = Fit (record , top = 60 )
227227 body = [text (fit .left + fit .width / 2 , 30 , title )]
@@ -280,7 +280,7 @@ def draw(fit):
280280 continue
281281 ex , ey = px + length_per_speed * fit .scale * u [k ], py - length_per_speed * fit .scale * v [k ]
282282 lines .append (
283- f'<line x1="{ fmt (px )} " y1="{ fmt (py )} " x2="{ fmt (ex )} " y2="{ fmt (ey )} " stroke="{ FLUX } " '
283+ f'<line x1="{ fmt (px )} " y1="{ fmt (py )} " x2="{ fmt (ex )} " y2="{ fmt (ey )} " stroke="{ FLOW } " '
284284 'stroke-width="1.2" marker-end="url(#arrow-small)"/>'
285285 )
286286 marker = (
@@ -321,22 +321,22 @@ def py(y):
321321 body += [text (24 , (top + bottom ) / 2 , y_label , rotate = - 90 )]
322322 for points , dashed , markers , name , name_at in series :
323323 dash = ' stroke-dasharray="5 4"' if dashed else ""
324- color = INK if dashed else FLUX # References dashed in ink, FEAScript in flow blue
324+ color = INK if dashed else FLOW # References dashed in ink, FEAScript in flow blue
325325 if points :
326326 path = " " .join (f"{ fmt (px (x ))} ,{ fmt (py (y ))} " for x , y in points )
327327 body .append (f'<polyline points="{ path } " fill="none" stroke="{ color } " stroke-width="2"{ dash } />' )
328328 if markers :
329- body += [dot (px (x ), py (y ), 3.5 , filled = False , color = FLUX ) for x , y in markers ]
329+ body += [dot (px (x ), py (y ), 3.5 , filled = False , color = FLOW ) for x , y in markers ]
330330 if name :
331331 x , y = points [name_at ]
332332 body .append (f'<text x="{ fmt (px (x ) + 8 )} " y="{ fmt (py (y ) - 8 )} " font-size="13" { HALO } >{ name } </text>' )
333333 for k , (dashed , marker , name ) in enumerate (legend ):
334334 ly = top + 18 + 22 * k
335335 if marker :
336- body .append (dot (left + 34 , ly , 3.5 , filled = False , color = FLUX ))
336+ body .append (dot (left + 34 , ly , 3.5 , filled = False , color = FLOW ))
337337 else :
338338 dash = ' stroke-dasharray="5 4"' if dashed else ""
339- body .append (f'<line x1="{ left + 18 } " y1="{ ly } " x2="{ left + 50 } " y2="{ ly } " stroke="{ INK if dashed else FLUX } " stroke-width="2"{ dash } />' )
339+ body .append (f'<line x1="{ left + 18 } " y1="{ ly } " x2="{ left + 50 } " y2="{ ly } " stroke="{ INK if dashed else FLOW } " stroke-width="2"{ dash } />' )
340340 body .append (f'<text x="{ left + 60 } " y="{ ly + 4 } " font-size="13" { HALO } >{ name } </text>' )
341341 return svg (width , height , body , comment )
342342
@@ -363,7 +363,7 @@ def hermite_deflection(record, samples=20):
363363# ── 1D domains ──────────────────────────────────────────────────────────────
364364
365365
366- def domain_1d (record , left , right , length_label , comment , regions = None , title = None ):
366+ def domain_1d (record , left , right , length_label , comment , regions = None , title = None , colors = None ):
367367 """1D mesh: element end nodes as open circles, midside nodes of quadratic elements as dots."""
368368 x0 , x1 , y = 80 , 500 , 130
369369 xs = record ["x" ]
@@ -385,7 +385,8 @@ def px(x):
385385 body .append (f'<circle cx="{ fmt (px (x ))} " cy="{ y } " r="2"/>' )
386386 else :
387387 body .append (dot (px (x ), y , 4 , filled = False ))
388- body += [dot (x0 , y , 5 , color = kind (left )), dot (x1 , y , 5 , color = kind (right ))]
388+ left_color , right_color = colors or (kind (left ), kind (right ))
389+ body += [end_dot (x0 , y , left_color ), end_dot (x1 , y , right_color )]
389390 body += [text (x0 , y - 26 , left ), text (x0 , y - 44 , bname ("left" ), 12 , "#666" )]
390391 body += [text (x1 , y - 26 , right ), text (x1 , y - 44 , bname ("right" ), 12 , "#666" )]
391392 body += dimension (x0 , y + 55 , x1 , y + 55 , length_label , offset_y = 20 )
@@ -451,8 +452,8 @@ def rhomboid_geometry():
451452 frame = Frame (140 , 260 , 80 )
452453 corners = [(0 , 0 ), (4 , 0 ), (5 , 2 ), (1 , 2 )]
453454 body = [outline ([frame (x , y ) for x , y in corners ], filled = True )]
454- body += [edge ([frame (0 , 0 ), frame (4 , 0 )], VALUE ), edge ([frame (4 , 0 ), frame (5 , 2 )], VALUE )]
455- body += [edge ([frame (5 , 2 ), frame (1 , 2 )], ROBIN ), edge ([frame (1 , 2 ), frame (0 , 0 )], ZERO )]
455+ body += [edge ([frame (0 , 0 ), frame (4 , 0 )], HEAT ), edge ([frame (4 , 0 ), frame (5 , 2 )], HEAT )]
456+ body += [edge ([frame (5 , 2 ), frame (1 , 2 )], GOLD ), edge ([frame (1 , 2 ), frame (0 , 0 )], ZERO )]
456457 body += label (* frame (2 , 0 ), f"{ T } = 200 °C" , bname ("bottom" ), "bottom" )
457458 body += label (* frame (3 , 2 ), H_CONV , bname ("top" ), "top" )
458459 body += slanted_label (* frame (0.5 , 1 ), "Symmetry" , bname ("left" ), * RHOMBOID_LEFT )
@@ -491,7 +492,7 @@ def solidification_geometry():
491492 return rect_geometry (4 , 2 , sides , [(f"|∇{ italic ('u' )} | = 1" , (2 , 1 ))], "Solidification front: 4 m x 2 m" )
492493
493494
494- def wall_geometry (name , left , right , regions , comment ):
495+ def wall_geometry (name , left , right , regions , comment , right_color = None ):
495496 """A wall of width 0.15 m, hatched, with its left and right conditions."""
496497 x0 , x1 , y0 , y1 = 210 , 350 , 50 , 230
497498 body = [f'<rect x="{ x0 } " y="{ y0 } " width="{ x1 - x0 } " height="{ y1 - y0 } " fill="{ AREA } "/>' ]
@@ -507,7 +508,7 @@ def wall_geometry(name, left, right, regions, comment):
507508 if start > 0 :
508509 body .append (f'<line x1="{ fmt (a )} " y1="{ y0 } " x2="{ fmt (a )} " y2="{ y1 } " stroke="#000" stroke-width="1" stroke-dasharray="5 4"/>' )
509510 body .append (f'<rect x="{ x0 } " y="{ y0 } " width="{ x1 - x0 } " height="{ y1 - y0 } " fill="none" stroke="#000" stroke-width="2"/>' )
510- body += [edge ([(x0 , y0 ), (x0 , y1 )], kind (" " .join (left ))), edge ([(x1 , y0 ), (x1 , y1 )], kind (" " .join (right )))]
511+ body += [edge ([(x0 , y0 ), (x0 , y1 )], kind (" " .join (left ))), edge ([(x1 , y0 ), (x1 , y1 )], right_color or kind (" " .join (right )))]
511512 for k , content in enumerate (left ):
512513 body .append (text (x0 - 16 , 115 + 21 * k , content , anchor = "end" ))
513514 body .append (text (x0 - 16 , 115 + 21 * len (left ), '"left"' , 12 , "#666" , "end" ))
@@ -531,7 +532,7 @@ def line_domain_geometry(length_label, left, right, equation, comment, source=No
531532 body += [f'<line x1="{ x0 } " y1="{ y } " x2="{ x1 } " y2="{ y } " stroke="#000" stroke-width="2"/>' , dot (x0 , y , 4 , filled = False ), dot (x1 , y , 4 , filled = False )]
532533 if source :
533534 body += source (x0 , x1 , y )
534- body += [dot (x0 , y , 5 , color = kind (left )), dot (x1 , y , 5 , color = kind (right ))]
535+ body += [end_dot (x0 , y , kind (left )), end_dot (x1 , y , kind (right ))]
535536 body += [text (x0 , y + 28 , left ), text (x0 , y + 44 , bname ("left" ), 12 , "#666" )]
536537 body += [text (x1 , y + 28 , right ), text (x1 , y + 44 , bname ("right" ), 12 , "#666" )]
537538 body += dimension (x0 , y + 75 , x1 , y + 75 , length_label , offset_y = 20 )
@@ -554,10 +555,10 @@ def second_derivative(variable="u"):
554555
555556def cantilever_geometry ():
556557 body = [f'<rect x="100" y="115" width="400" height="10" fill="{ AREA } " stroke="#000" stroke-width="2"/>' ]
557- body += [f '<line x1="100" y1="65" x2="100" y2="175" stroke="{ VALUE } " stroke-width="4"/>' , '<g stroke="#000" stroke-width="1">' ]
558+ body += ['<line x1="100" y1="65" x2="100" y2="175" stroke="#000 " stroke-width="4"/>' , '<g stroke="#000" stroke-width="1">' ]
558559 body += [f' <line x1="100" y1="{ 71 + 14 * k } " x2="88" y2="{ 83 + 14 * k } "/>' for k in range (8 )]
559560 body += ["</g>" ] + [dot (100 + 100 * k , 120 ) for k in range (5 )]
560- body += [f'<line x1="500" y1="40" x2="500" y2="110" stroke="{ FLUX } " stroke-width="2.5" marker-end="url(#arrow-flux )"/>' ]
561+ body += [f'<line x1="500" y1="40" x2="500" y2="110" stroke="{ STRUCTURE } " stroke-width="2.5" marker-end="url(#arrow-structure )"/>' ]
561562 body += [text (512 , 58 , f"{ italic ('P' )} = −1000 N" , anchor = "start" ), text (512 , 76 , 'node "5"' , 12 , "#666" , "start" )]
562563 body += [text (100 , 196 , "Clamped" ), text (100 , 212 , 'node "1"' , 12 , "#666" )]
563564 body += [text (300 , 90 , f"{ italic ('EI' )} = 10<tspan dy=\" -6\" font-size=\" 11\" >5</tspan><tspan dy=\" 6\" > N·m²</tspan>" )]
@@ -573,8 +574,8 @@ def cantilever_geometry():
573574def figures ():
574575 out = {}
575576 wall = load ("heatConduction1DWall" )
576- out ["wall-geometry" ] = wall_geometry ("wall" , ["Convection" , f"{ italic ('h' )} = 1 W/(m²·K)" , f"{ T } { sub ('∞' )} = 25 °C" ], ["Constant temperature" , f"{ T } = 5 °C" ], [(0 , 0.15 , "sparse" )], "1D wall, 0.15 m" )
577- out ["wall-mesh" ] = domain_1d (wall , "Convection" , f"{ T } = 5 °C" , "0.15 m" , "1D wall: 10 linear elements" )
577+ out ["wall-geometry" ] = wall_geometry ("wall" , ["Convection" , f"{ italic ('h' )} = 1 W/(m²·K)" , f"{ T } { sub ('∞' )} = 25 °C" ], ["Constant temperature" , f"{ T } = 5 °C" ], [(0 , 0.15 , "sparse" )], "1D wall, 0.15 m" , right_color = COLD )
578+ out ["wall-mesh" ] = domain_1d (wall , "Convection" , f"{ T } = 5 °C" , "0.15 m" , "1D wall: 10 linear elements" , colors = ( GOLD , COLD ) )
578579 out ["wall-results" ] = line_plot ([(nodal_series (wall ), False , nodal_series (wall ), None , 0 )], f"{ italic ('x' )} (m)" , f"{ T } (°C)" , [0 , 0.05 , 0.1 , 0.15 ], [5 , 6 , 7 , 8 ], "1D wall: temperature" )
579580
580581 varying_k = load ("heatConduction1DVaryingK" )
@@ -615,7 +616,7 @@ def figures():
615616 front = load ("solidificationFront2D" )
616617 out ["solidification-geometry" ] = solidification_geometry ()
617618 out ["solidification-mesh" ] = mesh_figure (front , RECT_SIDES , "12 × 8 quadratic quadrilaterals, 425 nodes" , "Solidification front: structured mesh" )
618- out ["solidification-results" ] = contour_figure (front , front ["solution" ], [0.25 * k for k in range (1 , 8 )], f"Front arrival { italic ('u' )} (distance from the initial front)" , "Solidification front: contours of u" , color = ROBIN )
619+ out ["solidification-results" ] = contour_figure (front , front ["solution" ], [0.25 * k for k in range (1 , 8 )], f"Front arrival { italic ('u' )} (distance from the initial front)" , "Solidification front: contours of u" , color = GOLD )
619620
620621 cavity = load ("lidDrivenCavity2DCreepingFlow" )
621622 out ["cavity-geometry" ] = cavity_geometry ()
0 commit comments