Changeset 2486 in lmdz_wrf


Ignore:
Timestamp:
Apr 30, 2019, 3:08:19 AM (6 years ago)
Author:
lfita
Message:

Adding individual angles for head and main sails

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2485 r2486  
    676676
    677677def zsailing_boat(length=10., beam=1., lbeam=0.4, sternbp=0.5, lmast=0.6, wmast=0.1, \
    678   sd=0., lheads=0.38, lmains=0.55):
     678  hsd=5., msd=5., lheads=0.38, lmains=0.55):
    679679    """ Function to define an schematic sailing boat from the z-plane with sails
    680680      length: length of the boat (without stern, default 10)
     
    684684      lmast: position of the mast (as percentage of length, default 0.6)
    685685      wmast: width of the mast (default 0.1)
    686       sd: sails direction respect to center line (default 0.)
     686      hsd: head sail direction respect to center line (default 5.)
     687      msd: main sail direction respect to center line (default 5.)
    687688      lheads: length of head sail (as percentage of legnth, defaul 0.38)
    688689      lmains: length of main sail (as percentage of legnth, defaul 0.55)
     
    712713    # head sails
    713714    lsail = lheads*length
    714     sailsa = np.pi/2. - np.pi*5./180. - np.pi*sd/180.
     715    sailsa = np.pi/2. - np.pi*hsd/180.
    715716    endsail = np.array([lsail*np.sin(sailsa), lsail*np.cos(sailsa)])
    716717    endsail[0] = length - endsail[0]
    717     hsail = circ_sec(endsail, bow, lsail*2.15)
     718    if bow[1] < endsail[1]:
     719        hsail = circ_sec(endsail, bow, lsail*2.15)
     720    else:
     721        hsail = circ_sec(bow, endsail, lsail*2.15)
    718722
    719723    # main sails
     724    sailsa = np.pi/2. - np.pi*msd/180.
    720725    lsail = lmains*length
     726    begsail = np.array([length*lmast, 0.])
    721727    endsail = np.array([lsail*np.sin(sailsa), lsail*np.cos(sailsa)])
    722728    endsail[0] = length*lmast - endsail[0]
    723     msail = circ_sec(endsail, np.array([length*lmast, 0.]), lsail*2.15)
     729    if endsail[1] < begsail[1]:
     730        msail = circ_sec(begsail, endsail, lsail*2.15)
     731    else:
     732        msail = circ_sec(endsail, begsail, lsail*2.15)
    724733
    725734    sailingboat = np.zeros((dpts*8+4,2), dtype=np.float)
     
    743752      '_lb' + str(int(lbeam*100.)) + '_sb' + str(int(sternbp*100.)) +                \
    744753      '_lm' + str(int(lmast*100.)) + '_wm' + str(int(wmast)) +                       \
    745       '_sd' + str(int(sd)) + '_hs' + str(int(lheads*100.)) +                         \
    746       '_ms' + str(int(lheads*100.)) + '.dat'
     754      '_hsd' + str(int(hsd)) + '_hs' + str(int(lheads*100.)) +                       \
     755      '_ms' + str(int(lheads*100.)) + '_msd' + str(int(msd)) +'.dat'
    747756    if not os.path.isfile(fname):
    748757        print infmsg
     
    752761          'length_at_max_beam:' + str(lbeam) + '% beam at stern: ' + str(sternbp)+   \
    753762          ' % mast position: '+ str(lmast) + ' % mast width: ' + str(wmast) + ' ' +  \
    754           ' sails direction:' + str(sd) + ' head sail length: ' + str(lheads) + ' %'+\
    755           ' main sail length' + str(lmains) + '\n')
     763          ' head sail direction:' + str(hsd) + ' head sail length: ' + str(lheads) + \
     764          ' %' + ' main sail length' + str(lmains) + ' main sail direction:' +       \
     765          str(msd) +'\n')
    756766        for ip in range(dpts*5):
    757767            of.write(str(sailingboat[ip,0]) + ' ' + str(sailingboat[ip,1]) + '\n')
Note: See TracChangeset for help on using the changeset viewer.