ukaea / paramak

Create parametric 3D fusion reactor CAD models
https://paramak.readthedocs.io/en/main/
36 stars 12 forks source link

Example for varible offset first wall #784

Open shimwell opened 3 years ago

shimwell commented 3 years ago

random_offsets

Threw together a quick example for a variable offset firstwall from a plasma that might be handy to add to the examples scripts as a PR



from numpy.lib.function_base import angle
import paramak
import random
import subprocess

# removes old files
subprocess.call(['rm', 'random_offset_*.svg'])

for counter in range(10):

    # gets 5 random numbers for the offsets
    offset_1 = random.uniform(10, 80)
    offset_2 = random.uniform(10, 80)
    offset_3 = random.uniform(10, 80)
    offset_4 = random.uniform(10, 80)
    offset_5 = random.uniform(10, 80)

    offsets = [offset_1, offset_2, offset_3, offset_4, offset_5, offset_1]

    # Simple plasma to offset, other more complex parametric plasma shapes are availbe, see the docs
    # https://paramak.readthedocs.io/en/main/paramak.parametric_components.html#plasmaboundaries
    plasma = paramak.Plasma(
            rotation_angle=35,
            minor_radius=150.0,
            major_radius=450.0,
            triangularity=0.55,
            elongation=2.0,
    )

    # shape build around plasma with non uniform offsets in this case
    firstwall = paramak.BlanketFP(
        plasma=plasma,
        rotation_angle=35,
        thickness=1,
        start_angle=0,
        stop_angle=360,
        offset_from_plasma=offsets  # uses a list in this case but accepts a single number, list or function
    )

    both_shapes = paramak.Reactor([plasma, firstwall])

    filename = 'random_offset_'+str(counter).zfill(3)+'.svg'

    # saves 3d geomery as svg image, could also be saved as html, stl, or stp
    both_shapes.export_svg(
        filename=filename,
        projectionDir=(5,-5,0),
        showHidden=True,
    )

# converts svg images to igf
subprocess.check_call(
    ["convert", "-delay", "40", "random_offset_*.svg", "random_offsets.gif"])
RemDelaporteMathurin commented 3 years ago

It seems the thickness of the blanket is not constant. Is it normal ?

billingsley-john commented 3 years ago

It seems the thickness of the blanket is not constant. Is it normal ?

I think it looks like the thickness is not constant because of the viewing plane of the svg image. Exporting stp files and viewing on correct plane shows constant thickness

RemDelaporteMathurin commented 3 years ago

@billingsley-john @Shimwell I get it, this is a compound of a plasma and a very very thin blanket.

Maybe runing it with a thickness of 10 makes the distinction between plasma and blanket clearer?

image