Skip to content

Example for varible offset first wall #784

Description

@shimwell

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"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions