• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NREL / WindSE / 5524291866

pending completion
5524291866

push

github

web-flow
Update main (#104)

* minor change to warning text

* shift gauss cyld by RD

* fixed cyld, converted point to expression

* fixed jit problem

* added sharpness param to point blockage

* fixed u_k update for constraints

* fixed taylor test convergence

* Added check_totals option

* fixed constraint derivatives, and taylor test inputs

* ALM DEL method

* default params

* updating yaml params

* moving example to demo folder

* renaming example folder

* starting on acuator disks

* fixed inflow angle bug

* made the multiangle solver more robust

* fixing what the fix broke

* yep

* Added fatpack to the install script

* added pandas

* got dolfin actuator disks working

* gotta fix a form_compiler issue, but it seems all good up to the gradient

* got numpy disks working

* added stop_annotation to the debug, and changed how boundary HH velocity calculated

* updated some demos/test, fixed objectives

* initial commit to compare to refactored ALM output to dev

* test push upstream

* minor cleaning after verifying results match

* adding power calc and more cleanup

* getting ready for optimization test

* adding test file for collaborating on optimization

* storing before opt testing original branch

* pushing latest mpi_u_fluid deriv testing

* adding latest test updates

* cleaning up ALM block tests

* syncing print statements for jeff

* refactored imported wind farms

* added empty farm, updated demos/test/docs

* fixed alm adjoint bug, got all test running

* moved test_alm_refactor.yaml to other folder so it doesn't get picked up by pytest

* fixing conflicts before factoring out trans/rots

* wrap values e.g. self.mz as float to avoid jit error

* factoring translation/rotation out of u-fluid and alm

* consistent var names prev vs behind

* fix alm gradients

* take two

* fixing merge conflicts

* fixing mz dijitso error

* added missi... (continued)

4003 of 4003 new or added lines in 47 files covered. (100.0%)

4546 of 7192 relevant lines covered (63.21%)

0.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

36.67
/windse/objective_functions/VelocityFunction.py
1
################## HEADER DO NOT EDIT ##################
2
import os
1✔
3
import __main__
1✔
4

5
### Get the name of program importing this package ###
6
if hasattr(__main__,"__file__"):
1✔
7
    main_file = os.path.basename(__main__.__file__)
1✔
8
else:
9
    main_file = "ipython"
×
10
    
11
### This checks if we are just doing documentation ###
12
if not main_file in ["sphinx-build", "__main__.py"]:
1✔
13
    from dolfin import *
1✔
14
    from dolfin_adjoint import *
1✔
15
########################################################
16

17
# Feel free to rename this file anything. if the file starts with a '_',
18
# it will be ignored in the import.
19

20
### Additional import statements ###
21
import numpy as np
1✔
22

23
### Declare Unique name
24
name = "velocity_function"
1✔
25

26
### Run this code to see which names are already taken ###
27
# import windse.objective_functions as obj_funcs
28
# print(obj_funcs.objective_functions.keys())
29
# print(obj_funcs.objective_kwargs)
30
# exit()
31

32
### Set default keyword argument values ###
33
# These must be a dictionary and will be passed in via the kwargs.
34
# Leave empty if no argument are needed. 
35
keyword_defaults = {
1✔
36
    "velocity_path": None,
37
}
38

39

40
### Define objective function
41
def objective(solver, inflow_angle = 0.0, first_call=False, **kwargs):
1✔
42
    '''
43
    Description of objective function
44

45
    Keyword arguments:
46
        velocity_path: location of the velocity profile csv file, columns: vel_x, vel_y, vel_z, x, y, z, and a 1 row header
47
    '''
48

49
    # check if the velocity profile is already loaded
50
    if not hasattr(solver, "velocity_profile_target"):
×
51

52
        # you can extract any kwarg using
53
        velocity_path = kwargs.pop("velocity_path")
×
54
        solver.fprint(f"Loading Velocity: {velocity_path}")
×
55

56
        # Get the function space ###
57
        V = solver.problem.fs.V
×
58

59
        # Load Velocity Data
60
        raw_data = np.loadtxt(velocity_path, skiprows=1, delimiter=",").T
×
61

62
        # Create velocity target
63
        vel = Function(V)
×
64

65
        # reformat velocity data
66
        stacked_data = np.zeros(vel.vector().get_local().shape)
×
67
        stacked_data[0::3] = raw_data[0]
×
68
        stacked_data[1::3] = raw_data[1]
×
69
        stacked_data[2::3] = raw_data[2]
×
70

71
        # convert velocity data to a dolfin function
72
        d2v = dof_to_vertex_map(V)
×
73
        vel.vector()[:] = stacked_data[d2v]
×
74

75
        # save velocity to the solver
76
        solver.velocity_profile_target = vel
×
77

78
        # save velocity file 
79
        solver.params.Save(solver.velocity_profile_target,"velocity_profile_target",subfolder="functions/")
×
80

81

82
    # Compute difference in velocity
83
    vel_diff = solver.velocity_profile_target - solver.problem.u_k
×
84
    J = assemble(dot(vel_diff, vel_diff)*dx)/solver.problem.dom.volume
×
85

86
    solver.fprint(f"Velocity Difference: {float(J)}")
×
87
    # solver.fprint(f"Velocity errornorm: {errornorm(solver.velocity_profile_target,solver.problem.u_k)}")
88

89
    return J
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc